﻿SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PkIdTable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PkIdTable](
	[IDNum] [int] NOT NULL,
	[Code] [varchar](100) NOT NULL,
	[About] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageMenus]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageMenus](
	[MenuID] [int] NOT NULL,
	[MenuName] [varchar](50) NOT NULL,
	[ParentID] [int] NOT NULL,
	[MenuLevel] [int] NOT NULL,
	[LinkUrl] [varchar](300) NULL,
	[About] [varchar](200) NOT NULL,
	[SortNumber] [int] NOT NULL CONSTRAINT [DF_WebManageMenus_SortNumber]  DEFAULT ((0)),
	[UpdateDate] [datetime] NOT NULL,
	[Operator] [varchar](50) NULL,
	[Status] [int] NOT NULL,
 CONSTRAINT [PK_WebManageMenus] PRIMARY KEY CLUSTERED 
(
	[MenuID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'MenuID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单名称' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'MenuName'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'ParentID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单层级' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'MenuLevel'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后一级菜单连接地址' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'LinkUrl'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'说明' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'About'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序数字，按降序排列' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'SortNumber'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'UpdateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作人' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus', @level2type=N'COLUMN', @level2name=N'Operator'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台管理菜单' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageMenus'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebDepartments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebDepartments](
	[DepartmentID] [int] NOT NULL,
	[DepartmentName] [varchar](50) NOT NULL,
	[About] [varchar](500) NOT NULL,
	[ParentID] [int] NOT NULL,
	[SortNumber] [int] NOT NULL CONSTRAINT [DF_WebDepartments_SortNumber]  DEFAULT ((0)),
	[UpdateDate] [datetime] NOT NULL,
	[Operator] [varchar](50) NULL,
	[Status] [int] NOT NULL,
 CONSTRAINT [PK_WebDepartments] PRIMARY KEY CLUSTERED 
(
	[DepartmentID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'DepartmentID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门名称' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'DepartmentName'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门说明' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'About'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级部门ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'ParentID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序数字，按降序排列' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'SortNumber'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'UpdateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作人' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments', @level2type=N'COLUMN', @level2name=N'Operator'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司部门信息' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebDepartments'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageRoles](
	[ManageRoleID] [int] NOT NULL,
	[RoleName] [varchar](50) NOT NULL,
	[DepartmentID] [int] NOT NULL,
	[About] [varchar](200) NOT NULL,
	[UpdateDate] [nchar](10) NOT NULL,
	[SortNumber] [int] NOT NULL CONSTRAINT [DF_WebManageRoles_SortNumber]  DEFAULT ((0)),
	[Operator] [varchar](50) NOT NULL,
	[Status] [int] NOT NULL,
 CONSTRAINT [PK_WebManageRoles] PRIMARY KEY CLUSTERED 
(
	[ManageRoleID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职位ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'ManageRoleID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职位名称' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'RoleName'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属部门ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'DepartmentID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关于职位' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'About'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'UpdateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序数字，按降序排列' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'SortNumber'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作人' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'Operator'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态 100 - 正常  200 - 只读  ' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles', @level2type=N'COLUMN', @level2name=N'Status'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台管理职位' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRoles'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageUser_Strategy]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageUser_Strategy](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ManageUserID] [int] NOT NULL,
	[IPArea] [nvarchar](50) NULL,
	[BeginDate] [datetime] NOT NULL CONSTRAINT [DF_WebManageUser_Strategy_BeginDate]  DEFAULT (getdate()),
	[EndDate] [datetime] NOT NULL,
	[Status] [int] NOT NULL CONSTRAINT [DF_WebManageUser_Strategy_Status]  DEFAULT ((1)),
	[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_WebManageUser_Strategy_CreateDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_WebManageUser_Strategy] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'策略编号' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'ID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台用户ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'ManageUserID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP地址区范围（*为通配符）' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'IPArea'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'该条策略起始时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'BeginDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'该项条策略结束时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'EndDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态（ -1:删除  0 :账户有效  9:禁止登录）' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'Status'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy', @level2type=N'COLUMN', @level2name=N'CreateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'后台用户登录控制策略表' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_Strategy'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageRole_WebManageMenus]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageRole_WebManageMenus](
	[ManageRoleID] [int] NOT NULL,
	[MenuID] [int] NOT NULL,
 CONSTRAINT [PK_WebManageRole_WebManageMenus] PRIMARY KEY CLUSTERED 
(
	[ManageRoleID] ASC,
	[MenuID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职位ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRole_WebManageMenus', @level2type=N'COLUMN', @level2name=N'ManageRoleID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRole_WebManageMenus', @level2type=N'COLUMN', @level2name=N'MenuID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职位与菜单的对应关系表' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageRole_WebManageMenus'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageUsers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageUsers](
	[ManageUserID] [int] NOT NULL,
	[LoginName] [varchar](20) NOT NULL,
	[LoginNameSpell] [varchar](20) NOT NULL CONSTRAINT [DF_WebManageUsers_LoginNameSpell]  DEFAULT (''),
	[Password] [varchar](50) NOT NULL,
	[RealName] [varchar](20) NOT NULL,
	[Gender] [varchar](10) NOT NULL,
	[IntroductionURL] [varchar](500) NOT NULL CONSTRAINT [DF_WebManageUsers_IntroductionURL]  DEFAULT (''),
	[Phone] [varchar](20) NULL,
	[Mobile] [varchar](20) NOT NULL,
	[Email] [varchar](50) NULL,
	[AvatarUrl] [varchar](300) NOT NULL CONSTRAINT [DF_WebManageUsers_AvatarUrl]  DEFAULT (''),
	[QQ] [varchar](20) NULL,
	[MSN] [varchar](50) NULL,
	[Rtx] [varchar](20) NULL,
	[Birthday] [varchar](20) NULL,
	[Description] [nvarchar](max) NULL,
	[DepartmentID] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[UpdateDate] [datetime] NULL,
	[Operator] [varchar](50) NULL,
	[Status] [int] NOT NULL,
 CONSTRAINT [PK_WebUsers] PRIMARY KEY CLUSTERED 
(
	[ManageUserID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职员ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'ManageUserID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登录名' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'LoginName'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户拼音' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'LoginNameSpell'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Password'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'真实姓名' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'RealName'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Gender'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Phone'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手机' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Mobile'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮件地址' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Email'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职员头像' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'AvatarUrl'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ号码' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'QQ'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MSN号码' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'MSN'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'腾迅通号码' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Rtx'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生日' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Birthday'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'个人介绍' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Description'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'DepartmentID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'CreateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'UpdateDate'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'操作人真实姓名' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Operator'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态，100-正常，400-删除，500-冻结' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers', @level2type=N'COLUMN', @level2name=N'Status'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职员信息' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUsers'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WebManageUser_WebManageRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[WebManageUser_WebManageRoles](
	[ManageUserID] [int] NOT NULL,
	[ManageRoleID] [int] NOT NULL,
	[OperatorAuthority] [int] NOT NULL,
 CONSTRAINT [PK_WebManageUser_WebManageRoles] PRIMARY KEY CLUSTERED 
(
	[ManageUserID] ASC,
	[ManageRoleID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职员与职位对应关系表' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'WebManageUser_WebManageRoles'

GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebManageUser_Strategy_WebManageUsers]') AND parent_object_id = OBJECT_ID(N'[dbo].[WebManageUser_Strategy]'))
ALTER TABLE [dbo].[WebManageUser_Strategy]  WITH CHECK ADD  CONSTRAINT [FK_WebManageUser_Strategy_WebManageUsers] FOREIGN KEY([ManageUserID])
REFERENCES [dbo].[WebManageUsers] ([ManageUserID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebManageRole_WebManageMenus_WebManageMenus]') AND parent_object_id = OBJECT_ID(N'[dbo].[WebManageRole_WebManageMenus]'))
ALTER TABLE [dbo].[WebManageRole_WebManageMenus]  WITH CHECK ADD  CONSTRAINT [FK_WebManageRole_WebManageMenus_WebManageMenus] FOREIGN KEY([MenuID])
REFERENCES [dbo].[WebManageMenus] ([MenuID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebManageUsers_WebDepartments]') AND parent_object_id = OBJECT_ID(N'[dbo].[WebManageUsers]'))
ALTER TABLE [dbo].[WebManageUsers]  WITH CHECK ADD  CONSTRAINT [FK_WebManageUsers_WebDepartments] FOREIGN KEY([DepartmentID])
REFERENCES [dbo].[WebDepartments] ([DepartmentID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebManageUser_WebManageRoles_WebManageRoles]') AND parent_object_id = OBJECT_ID(N'[dbo].[WebManageUser_WebManageRoles]'))
ALTER TABLE [dbo].[WebManageUser_WebManageRoles]  WITH CHECK ADD  CONSTRAINT [FK_WebManageUser_WebManageRoles_WebManageRoles] FOREIGN KEY([ManageRoleID])
REFERENCES [dbo].[WebManageRoles] ([ManageRoleID])
